 /*    
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */ 


package virtualdocumentslibrary; 
 
 
import com.mysql.jdbc.PreparedStatement;
import java.awt.Color;
import java.awt.Toolkit;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import static virtualdocumentslibrary.DataBaseClass.connection;

/**
 *
 * @author Javier_Alay
 */
public class NewFondo extends javax.swing.JFrame {

    /**
     * Creates new form NewFondo 
     */
    
    private javax.swing.JTree fondos;
    private MasterMainView mmv;
    private boolean nuevo;
    private String nombre;
    private int isSerie;
    private String[] identificador = null;
    private String identificadorActual = null;
    private Deque<String> ids;
    private Deque<String> nombres;
    private int codigoUsuario;
    private String oldName;
    private String oldId;
    public NewFondo() {
        initComponents();
        //Set the icon of the app. 
        this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Imagenes/iconApp.png"))); 
        this.setTitle("Virtual Archive");
    }

    //constructor para un nuevo fondo
    public NewFondo(String[] datos, javax.swing.JTree fondos, MasterMainView mmv, int codigoUsuario) {
        initComponents();
        //Set the icon of the app. 
        this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Imagenes/iconApp.png"))); 
        this.setTitle("Virtual Archive");
        int Red = Integer.parseInt(datos[4]);
        int Green = Integer.parseInt(datos[5]);
        int Blue = Integer.parseInt(datos[6]);
        Color bgColor = new Color(Red,Green,Blue);
        principalPanel.setBackground(bgColor);
        this.fondos = fondos;
        this.mmv = mmv;        
        this.nuevo = true;
        isSerie = 0;
        ids = new ArrayDeque<String>();
        
        
        this.codigoUsuario = codigoUsuario;
        nombres = new ArrayDeque<String>();
        
    }
    
    //constructor para modificar 
    public NewFondo(String[] datos, javax.swing.JTree fondos, MasterMainView mmv, String nombre, String fondo, int codigoUsuario) {
        initComponents();
        //Set the icon of the app. 
        this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Imagenes/iconApp.png"))); 
        this.setTitle("Virtual Archive");
        int Red = Integer.parseInt(datos[4]);
        int Green = Integer.parseInt(datos[5]);
        int Blue = Integer.parseInt(datos[6]);
        Color bgColor = new Color(Red,Green,Blue);
        principalPanel.setBackground(bgColor);
        this.fondos = fondos;
        this.mmv = mmv;     
        this.nuevo = false;
        titleLabel.setText("Modificar"); 
        newFondoname.setText(nombre);
        this.oldName = nombre;
        String id[] = BDEstructura.getIdentificadoresByUser(fondos.getSelectionPath().getLastPathComponent().toString());
        newIdentificador.setText(id[0]);
        this.oldId = id[0];
        this.nombre = nombre;
        this.isSerie = BDEstructura.isSerie(nombre,fondo);
        
        ids = new ArrayDeque<String>();
        
        this.codigoUsuario = codigoUsuario; 
        nombres = new ArrayDeque<String>();
        newIdentificador.setEditable(false);
    }
    
    //constructor para nueva serie
    public NewFondo(String[] datos, javax.swing.JTree fondos, MasterMainView mmv, int isSerie, int codigoUsuario) {
        initComponents();
        //Set the icon of the app. 
        this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Imagenes/iconApp.png"))); 
        this.setTitle("Virtual Library");
        int Red = Integer.parseInt(datos[4]);
        int Green = Integer.parseInt(datos[5]);
        int Blue = Integer.parseInt(datos[6]);
        Color bgColor = new Color(Red,Green,Blue);
        principalPanel.setBackground(bgColor);
        this.fondos = fondos;
        this.mmv = mmv;     
        this.nuevo = true;
        titleLabel.setText("Nueva Serie");
        this.isSerie = isSerie;  
        
        ids = new ArrayDeque<String>();
         
        this.codigoUsuario = codigoUsuario;
        nombres = new ArrayDeque<String>();
    }
    /** 
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        principalPanel = new javax.swing.JPanel();
        titleLabel = new javax.swing.JLabel();
        submitButton = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        newFondoname = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        newIdentificador = new javax.swing.JTextField();

        principalPanel.setBackground(new java.awt.Color(255, 102, 0));

        titleLabel.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
        titleLabel.setText("Nuevo Fondo / Sub Fondo");

        javax.swing.GroupLayout principalPanelLayout = new javax.swing.GroupLayout(principalPanel);
        principalPanel.setLayout(principalPanelLayout);
        principalPanelLayout.setHorizontalGroup(
            principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(principalPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(140, Short.MAX_VALUE))
        );
        principalPanelLayout.setVerticalGroup(
            principalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, principalPanelLayout.createSequentialGroup()
                .addContainerGap(23, Short.MAX_VALUE)
                .addComponent(titleLabel)
                .addContainerGap())
        );

        submitButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/aceptar.png"))); // NOI18N
        submitButton.setText("Ingresar");
        submitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                submitButtonActionPerformed(evt);
            }
        });

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/cancelar.png"))); // NOI18N
        jButton2.setText("Cancelar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel1.setText("Nombre:");

        jLabel2.setText("Identificador:");

        newIdentificador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newIdentificadorActionPerformed(evt);
            }
        });
        newIdentificador.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                newIdentificadorKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(principalPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(submitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18))
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(newFondoname, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(newIdentificador))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton2, submitButton});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(principalPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(newFondoname, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(newIdentificador, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(submitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton2, submitButton});

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    public boolean checkNameIfExist(Object fondoName,String nameToCheck){
        String nameSinEspacios = "";
        int existNTimes = 0;
        for(int i=0;i<nameToCheck.length();i++){
            if(nameToCheck.charAt(i) != ' '){
                nameSinEspacios += nameToCheck.charAt(i);
            }
        }
        
        printChilds((DefaultMutableTreeNode) fondoName);
        Object[] hijosDelFondo = this.nombres.toArray();
        String hijoSinEspacios = "";
        for(int i=0;i<hijosDelFondo.length;i++){
            hijoSinEspacios = "";
            for(int j=0;j<hijosDelFondo[i].toString().length();j++){
                if(hijosDelFondo[i].toString().charAt(j) != ' '){
                    hijoSinEspacios += hijosDelFondo[i].toString().charAt(j);
                }
            }
            
            if(nameSinEspacios.equalsIgnoreCase(hijoSinEspacios)){
                existNTimes++;
            }
            
            
        }
        if(existNTimes>0){
            return true;
        }
        else{
            return false;
        }
        
    }
    
    public boolean checkIdIfExist(String newId){
        int existNTimes = 0;
        String newIdSinEspacio = "";
        for(int i=0;i<newId.length();i++){
            if(newId.charAt(i) != ' '){
                newIdSinEspacio += newId.charAt(i);
            }
        }
        String[] namesInFondo = new String[this.nombres.size()];
        int contador = 0;
        while(!this.nombres.isEmpty()){
            namesInFondo[contador] = this.nombres.pop();
            contador++;
        }
        for(int i=0;i<namesInFondo.length;i++){
            String[] id = BDEstructura.getIdentificadoresByUser(namesInFondo[i]);
            ids.push(id[0]);
        }
        Object[] idsA = ids.toArray();
        String existingId = "";
        for(int i=0;i<idsA.length;i++){
            existingId = "";
            for(int j=0;j<idsA[i].toString().length();j++){
                if(idsA[i].toString().charAt(j) != ' '){
                    existingId += idsA[i].toString().charAt(j);
                }
            }
            if(existingId.equalsIgnoreCase(newIdSinEspacio)){
                existNTimes ++;
            }
        }
        if(existNTimes>0){
            return true;
        }
        else{
            return false;
        }
    }
    
    private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitButtonActionPerformed
        String child = newFondoname.getText();
        String identificadorNuevo = newIdentificador.getText();
        String[] identificador = null;
        Object[] directorios = fondos.getSelectionPath().getPath();
        try{
            if(directorios.length>2){
                identificador = BDEstructura.getIdentificadores(fondos.getSelectionPath().getLastPathComponent().toString(),directorios[2].toString());
            }
            else{
                identificador = BDEstructura.getIdentificadores(fondos.getSelectionPath().getLastPathComponent().toString(),"null");
            }
            
            
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, "Error al crear nuevo : \nNo ha seleccionado un directorio donde crear","Error en creacion", 0);
            this.dispose();
        }
        
        
        int serieConsulta = 0;
        //verifico que el nombre y el identificador no existan ya en el fondo, si y solo si no es un fondo 
        
        
        boolean nameExist;
        boolean idExist;
        
        if(directorios.length > 2){
            if(nuevo){
                
                nameExist = checkNameIfExist(directorios[2],child);
                idExist = checkIdIfExist(identificadorNuevo);
            }
            else{
                if(child.equals(oldName)){
                    nameExist = false;
                    if(identificadorNuevo.equals(oldId)){
                        idExist = false;
                    }
                    else{
                        idExist = checkIdIfExist(identificadorNuevo);
                    }
                    
                }
                else{
                    nameExist = checkNameIfExist(directorios[2],child);
                    if(identificadorNuevo.equals(oldId)){
                        idExist = false;
                    }
                    else{
                        idExist = checkIdIfExist(identificadorNuevo);
                    }
                }
            }
        }
        else{
            Deque<String> nodes = BDEstructura.getNodesFromTheSameParent("Fondos");
            Deque<String> ids = BDEstructura.getIdsFromTheSameParent("Fondos");
            Object[] nodesA = nodes.toArray();
            Object[] idA = ids.toArray();
            
            String nameSinEspacios = "";
            int existNTimes = 0;
            for(int i=0;i<child.length();i++){
                if(child.charAt(i) != ' '){
                    nameSinEspacios += child.charAt(i);
                }
            }
            
            String hijoSinEspacios = "";
            for(int i=0;i<nodesA.length;i++){
                hijoSinEspacios = "";
                for(int j=0;j<nodesA[i].toString().length();j++){
                    if(nodesA[i].toString().charAt(j) != ' '){
                        hijoSinEspacios += nodesA[i].toString().charAt(j);
                    }
                }

                if(nameSinEspacios.equalsIgnoreCase(hijoSinEspacios)){
                    existNTimes++;
                }
                

            }
            if(existNTimes>0){
                nameExist = true;
            }
            else{
                nameExist = false;
            }
            
            // comprueba si existe el id
            int existIdNTimes = 0;
            String idSinEspacios = "";
            for(int i=0;i<identificadorNuevo.length();i++){
                if(identificadorNuevo.charAt(i) != ' '){
                    idSinEspacios += identificadorNuevo.charAt(i);
                }
            }
            
            String idExistenteSinEspacios = "";
            for(int i=0;i<idA.length;i++){
                idExistenteSinEspacios = "";
                for(int j=0;j<idA[i].toString().length();j++){
                    if(idA[i].toString().charAt(j) != ' '){
                        idExistenteSinEspacios += idA[i].toString().charAt(j);
                    }
                }

                if(idExistenteSinEspacios.equalsIgnoreCase(idSinEspacios)){
                    existIdNTimes++;
                }
                

            }
            if(existIdNTimes>0){
                idExist = true;
            }
            else{
                idExist = false;
            }
            
            
        }
        
        if(!nameExist & !idExist){
            //primero verifico si es serie o no
            if(isSerie == 0){
                //si no es serie entonces ingreso el fondo/subfondo

                //si es un fondo/ sub fondo nuevo entonces inserto la nueva estructura a la base de datos
                if(nuevo){ 
                    //antes de ingresar el fondo nuevo verifico que el papa no sea serie
                    if(directorios.length>2){
                        serieConsulta = BDEstructura.isSerie(fondos.getSelectionPath().getLastPathComponent().toString(),directorios[2].toString());
                    }
                    else{
                        serieConsulta = BDEstructura.isSerie(fondos.getSelectionPath().getLastPathComponent().toString(),"null");
                    }
                    
                    if(serieConsulta == 0){
                        String consulta = "";
                       
                        if(directorios.length>2){
                            consulta = "INSERT INTO Sub_Fondo VALUES (0,'id"+(BDEstructura.getLastId()+1)+"','"+child+"','"+identificador[0]+"','"+identificadorNuevo+"',0,'"+directorios[2]+"');";
                            
                        }
                        else{
                            consulta = "INSERT INTO Sub_Fondo VALUES (0,'id"+(BDEstructura.getLastId()+1)+"','"+child+"','"+identificador[0]+"','"+identificadorNuevo+"',0,null);";
                          
                        }
                        DataBaseClass.executeQuery(consulta);
                        createPermiso(child,"Permiso para ver el fondo/subfondo "+child,BDEstructura.getLastId());

                    }
                    else if(serieConsulta == 1){
                        JOptionPane.showMessageDialog(null, "No puede crear un sub fondo dentro de una serie","Error al crear el sub fondo", 0);
                    }


                }
                else{
                    //modifico los valores
                    int idModificar = 0;
                    if(directorios.length>2){
                        idModificar = BDEstructura.getIdSub_Fondo(nombre,directorios[2].toString());
                    }
                    else{
                        idModificar = BDEstructura.getIdSub_Fondo(nombre,"null");
                    }
                    String consulta = "UPDATE Sub_Fondo SET Nombre = '"+child+"', Identificador_Por_Usuario = '"+identificadorNuevo+"' WHERE idSub_Fondo = "+idModificar+"; ";
                    DataBaseClass.executeQuery(consulta);        

                }
            }
            else if(isSerie == 1){
                //si es una nueva serie entonces la ingreso a la base de datos
                if(nuevo){                
                    //antes de ingresar el fondo nuevo verifico que el papa no sea serie
                    if(directorios.length>2){
                        serieConsulta = BDEstructura.isSerie(fondos.getSelectionPath().getLastPathComponent().toString(),directorios[2].toString());
                    }
                    else{
                        serieConsulta = BDEstructura.isSerie(fondos.getSelectionPath().getLastPathComponent().toString(),"null");
                    }
                    if(serieConsulta == 0){
                        String consulta = "";
                        if(directorios.length>2){
                            consulta = "INSERT INTO Sub_Fondo VALUES (0,'id"+(BDEstructura.getLastId()+1)+"','"+child+"','"+identificador[0]+"','"+identificadorNuevo+"',1,'"+directorios[2]+"');";
                        }
                        else{
                            consulta = "INSERT INTO Sub_Fondo VALUES (0,'id"+(BDEstructura.getLastId()+1)+"','"+child+"','"+identificador[0]+"','"+identificadorNuevo+"',1,null);";
                        }
                        DataBaseClass.executeQuery(consulta);
                        createPermiso(child,"Permiso para ver la serie "+child,BDEstructura.getLastId());
                    } 
                    else if(serieConsulta == 1){
                        JOptionPane.showMessageDialog(null, "No puede crear una serie dentro de una serie","Error al crear Serie", 0);
                    }

                }  
                else{
                    //si es existente solo modifico los valores 
                    int idModificar = 0;
                    if(directorios.length>2){
                        idModificar = BDEstructura.getIdSub_Fondo(nombre,directorios[2].toString());
                    }
                    else{
                        idModificar = BDEstructura.getIdSub_Fondo(nombre,"null");
                    }
                    String consulta = "UPDATE Sub_Fondo SET Nombre = '"+child+"', Identificador_Por_Usuario = '"+identificadorNuevo+"' WHERE idSub_Fondo = "+idModificar+"; ";
                    DataBaseClass.executeQuery(consulta);        

                }

            }
            mmv.reloadTree(fondos); 
        
            dispose();
        }
        else{ 
            if(nameExist){
                JOptionPane.showMessageDialog(null, "Nombre ya existente, ingrese otro nombre","Error al ingresar", 0);
            }
            if(idExist){
                JOptionPane.showMessageDialog(null, "Identificador ya existente, ingrese otro identificador","Error al ingresar", 0);
            }
            
        }

        
    }//GEN-LAST:event_submitButtonActionPerformed

    
    
    public void printChilds(DefaultMutableTreeNode aNode)
    {
        String name = aNode.toString();
        if(aNode.isLeaf())
        {
            //aqui es si no tiene hijos
            this.nombres.push(name);
            return;
        }
        //aqui es si tiene hijos
        this.nombres.push(name);
        for(int i = 0 ; i < aNode.getChildCount() ; i++)
        {
            printChilds((DefaultMutableTreeNode)aNode.getChildAt(i));
        }
    }
    
    public void createPermiso(String nombreFondo, String Descripcion, int idSubFondo){
        try {
            Object[] directorios = fondos.getSelectionPath().getPath();
            PreparedStatement ps = null;
            ps = (PreparedStatement) connection.prepareStatement("INSERT INTO Permiso"
                    + " (Nombre,Descripcion,Codigo_Sub_Nivel) values (?,?,?)");
            if(directorios.length>2){
                ps.setString(1, "Permiso de id"+BDEstructura.getIdSub_Fondo(nombreFondo,directorios[2].toString()));
            }
            else{
                ps.setString(1, "Permiso de id"+BDEstructura.getIdSub_Fondo(nombreFondo,"null"));
            }
            
            ps.setString(2, Descripcion);
            ps.setInt(3, idSubFondo); 
            
            ps.executeUpdate();
            
               
            ps = (PreparedStatement) connection.prepareStatement("INSERT INTO Usuario_Permiso"
                    + " (Codigo_Permiso,Codigo_Usuario,Acces) values (?,?,?)");

            
            ps.setInt(1, BDEstructura.getLastIdPermiso());
            ps.setInt(2, codigoUsuario);
            ps.setInt(3, 1);
            
            ps.executeUpdate();
            
            int[] ids = BDEstructura.getIdFromUsers();
            for(int i=0;i<ids.length;i++){
                if(codigoUsuario == ids[i]){
                    
                }
                else{
                    ps = (PreparedStatement) connection.prepareStatement("INSERT INTO Usuario_Permiso"
                        + " (Codigo_Permiso,Codigo_Usuario,Acces) values (?,?,?)");


                    ps.setInt(1, BDEstructura.getLastIdPermiso());
                    ps.setInt(2, ids[i]);
                    ps.setInt(3, 0);

                    ps.executeUpdate();
                }
            }
            
            
        } catch (SQLException ex) {
            Logger.getLogger(NewFondo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void newIdentificadorKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_newIdentificadorKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_newIdentificadorKeyPressed

    private void newIdentificadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newIdentificadorActionPerformed
        // TODO add your handling code here:
        submitButtonActionPerformed(evt);
    }//GEN-LAST:event_newIdentificadorActionPerformed
    

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewFondo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewFondo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewFondo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewFondo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewFondo().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField newFondoname;
    private javax.swing.JTextField newIdentificador;
    private javax.swing.JPanel principalPanel;
    private javax.swing.JButton submitButton;
    private javax.swing.JLabel titleLabel;
    // End of variables declaration//GEN-END:variables
}
